package com.dh.spring.common;

import java.util.HashMap;
import java.util.Map;

public class HttpRequest {
    //TODO 请求信息
    private String requestHeader;
    //TODO body数据
    private String bodyData;
    //TODO header请求头集合
    private HeaderEntry headerEntry;

    public HttpRequest() {
        this.requestHeader = BasicConstant.DATA_EMPTY;
        this.bodyData = BasicConstant.DATA_EMPTY;
        this.headerEntry = new HttpRequest.HeaderEntry();
    }

    public static HttpRequest getInstance() {
        return new HttpRequest();
    }

    public String getRequestHeader() {
        return requestHeader;
    }

    public void setRequestHeader(String requestHeader) {
        this.requestHeader = requestHeader;
    }

    public String getBodyData() {
        return bodyData;
    }

    public void setBodyData(String bodyData) {
        this.bodyData = bodyData;
    }

    public HeaderEntry getHeaderEntry() {
        return headerEntry;
    }

    public void setHeaderEntry(HeaderEntry headerEntry) {
        this.headerEntry = headerEntry;
    }

    public void putHeader(String key, String value) {
        this.getHeaderEntry().setHeader(key, value);
    }

    public void getHeader(String key) {
        this.getHeaderEntry().getHeader(key);
    }

    class HeaderEntry {
        private Map<String, Object> map = new HashMap<>();

        public void setHeader(String key, String value) {
            map.put(key, value);
        }

        public String getHeader(String key) {
            return String.valueOf(map.get(key));
        }
    }
}
